package com.cgbl.cg.vm.mine

import android.app.Application
import androidx.databinding.ObservableInt
import api.ResourceServiceFactory
import com.robot.base.base.vm.GLBaseViewModel
import com.robot.base.common.api.AbstractViewModelSubscriber
import com.robot.base.model.PageListBean
import com.robot.base.model.ResourceBean
import me.goldze.mvvmhabit.binding.command.BindingAction
import me.goldze.mvvmhabit.binding.command.BindingCommand
import me.goldze.mvvmhabit.bus.event.SingleLiveEvent
import me.goldze.mvvmhabit.http.BaseResponse

class ResourceCenterViewModel (application: Application) : GLBaseViewModel(application) {

    val uc = UiChangeEvent()
    class UiChangeEvent{
        val refreshDataEvent = SingleLiveEvent<List<ResourceBean>>()
    }

    fun getMyNatural(){
        ResourceServiceFactory.getMyNatural()
            .subscribe(object :AbstractViewModelSubscriber<BaseResponse<PageListBean<ResourceBean>>>(this){
                override fun onNext(t: BaseResponse<PageListBean<ResourceBean>>) {
                    uc.refreshDataEvent.postValue(t.data.list)
                }
            })
    }
}